<template>
	<view>
		<view :style="{height:navTop+'px'}">
			
		</view>
		<view class="nav-container">
			<u-icon name="list-dot" size="28" @click="goCategory"></u-icon>
			<!-- #ifdef APP||APP-PLUS -->
			<u--input placeholder="请输入宝贝内容"  prefixIcon="search" :disabled="true" shape="circle" height="20" @click="goSearch"></u--input>
			<!-- #endif -->
			<!-- #ifndef APP -->
			<u-search placeholder="请输入宝贝名称" :showAction="false" :disabled="true" margin="10" @click="goSearch"></u-search>
			<!-- #endif -->
			<u-icon name="account" size="28"></u-icon>
		</view>
	</view>
</template>

<script>
	export default {
		name:"customNavigation",
		data() {
			return {
				navTop:0
			};
		},
		methods:{
			getAppNavTop(){
				//同步获取系统信息对象
				const systemInfo=uni.getSystemInfoSync();
				//在系统对象中获取状态栏的高度
				this.navTop=systemInfo.statusBarHeight;
			},
			getWexinNavTop(){
				//同步获取系统信息对象
				const systemInfo=uni.getSystemInfoSync();
				//在系统对象中获取状态栏的高度
				const statusHeight=systemInfo.statusBarHeight;
				//获取胶囊按钮对象
				const menuBtn=uni.getMenuButtonBoundingClientRect();
				//获取胶囊按钮距离顶部的距离
				console.log('top',menuBtn.top); 
				console.log('状态栏的高度',statusHeight); 
				const h=(menuBtn.top-statusHeight)*2+statusHeight+menuBtn.height
				console.log('h',h);
				this.navTop=h
			},
			goCategory(){
				uni.switchTab({
					url:'/pages/category/category'
				})
			},
			goSearch(){
				console.log('------123------');
				uni.navigateTo({
					url:'/pages/search/search'
				})
			}
		},
		mounted() {
			// #ifdef APP||APP-PLUS
			this.getAppNavTop()
			// #endif
			// #ifdef MP-WEIXIN
			this.getWexinNavTop()
			// #endif
		}
	}
</script>

<style lang="scss">
	.nav-container{
		display: flex;
		justify-content: space-between;
		width: 750rpx;
		height: 100rpx;
		background-color: hsla(0,0%,100%,.5);
		box-sizing: border-box;
		padding: 15rpx 10rpx;
		position: fixed;
		z-index: 999;
	}
</style>